﻿using System.Text;

namespace Fetches.Fetch.Utils.IdGenerator
{
    public class Id
    {
        /// <summary>
        /// 机器ID，最多支持1024台，内嵌服务器0-923
        /// </summary>
       public  long Machine { get; set; }
        /// <summary>
        /// 序列号，秒级支持百万级别，毫秒级单位时间1024个
        /// </summary>
        public long Seq { get; set; }
       /// <summary>
       /// 时间戳
       /// </summary>
       public long Time { get; set; }
       /// <summary>
       /// 生成方式，嵌入型00，中心服务器型01，REST发布05
       /// </summary>
       public long GenMethod { get; set; }
       /// <summary>
       /// 类型，最大峰值型0，最小粒度型1
       /// </summary>
       public long Type { get; set; }
       /// <summary>
       /// 版本号，用于扩容，对Fetches来说无意义
       /// </summary>
       public long Version { get; set; }

       public Id()
       {

       }

        public Id(long machine, long seq, long time, long genMethod, long type,
            long version)
        {
         
            Machine = machine;
            Seq = seq;
            Time = time;
            GenMethod = genMethod;
            Type = type;
            Version = version;
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("[");
            sb.Append("machine=").Append(Machine).Append(",");
            sb.Append("seq=").Append(Seq).Append(",");
            sb.Append("time=").Append(Time).Append(",");
            sb.Append("genMethod=").Append(GenMethod).Append(",");
            sb.Append("type=").Append(Type).Append(",");
            sb.Append("version=").Append(Version).Append("]");

            return sb.ToString();
        }
    }
}
